//
//  ZYNavigationController.m
//  VeiBo
//
//  Created by apple on 16/12/3.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ZYNavigationController.h"

@interface ZYNavigationController () <UIGestureRecognizerDelegate>

@end

@implementation ZYNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.interactivePopGestureRecognizer.delegate = self;
    
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    return self.childViewControllers.count != 1;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
   
    if (self.childViewControllers.count > 0) {
        
        NSString *title = @"返回";
        if (self.childViewControllers.count == 1) {
            
            title = self.childViewControllers.firstObject.title;
         
        }
         viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem ZY_setButtonItemImageName:@"navigationbar_back_withtext" title:title target:self action:@selector(backClick)];

    }
    

    [super pushViewController:viewController animated:animated];
}

- (void)backClick{
    
    [self popViewControllerAnimated:YES];
}

@end
